#include<bits/stdc++.h>
using namespace std;
int d[100010],v[100010],a[100010],p[100010],flag[100010];
float l=0,r=0;
int ans=0;
int main()
{
	freopen("detect.in","r",stdin);
	freopen("detect.out","w",stdout);
	int n,m,l,k,t;
	cin>>t>>n>>m>>l>>k;
	for(int i=1;i<=n;i++)
	{
		cin>>d[i];
		cin>>v[i];
		cin>>a[i];
	}
	for(int i=1;i<=m;i++)
	{
		cin>>p[i];
	}
	for(int i=1;i<=n;i++)
	{
		    if(a[i]>0&&v[i]>k)
			{
				l=d[i];
				r=l;
			}
			if(a[i]>0&&v[i]<=k)
			{
				l=d[i]+(k*k-v[i]*v[i])/(2*a[i]);
				r=l;
			}
			if(a[i]<0&&v[i]>k)
			{
				l=d[i];
				r=d[i]+(k*k-v[i]*v[i])/(2*a[i]);
			}
			if(a[i]<0&&v[i]<=k)
			{
				flag[i]=1;
			}
			if(a[i]==0&&v[i]>k)
			{
				l=d[i];
				r=l;
			}
			if(a[i]<0&&v[i]<=k)
			{
				flag[i]=1;
			}
		if(flag[i]!=1&&r>l)
		{
			for(int j=1;j<=m;j++)
			{
				if(p[j]>=l&&p[j]<=r&&a[i]>0&&v[i]>k)
				{
					flag[i]=2;
				}
				if(p[j]>l&&p[j]<=r&&a[i]>0&&v[i]<=k)
				{
					flag[i]=2;
				}
				if(p[j]>=l&&p[j]<r&&a[i]<0&&v[i]>k)
				{
					flag[i]=2;
				}
				if(p[j]>=l&&p[j]<=r&&a[i]==0&&v[i]>k)
				{
				     flag[i]=2;	
				}
			}
		}
	}
	for(int i=1;i<=n;i++)
	{
		if(flag[i]==2)
		{
			ans++;
		}
	}
	cout<<ans<<" "<<"3";
	return 0;
}
